package cn.hh.wechatkit.helper;

import cn.hh.wechatkit.param.WxParam;
import com.blade.kit.base.Config;
import lombok.Getter;
import lombok.Setter;

/**
 * Created this one by HMH on 2017/5/19.
 */

public class PropertiesConfigHelper {

    /*
      wechat app config 加载配置
     */

    public static void config(String wechatConfigPath) {

        Config wechatConfigProperties = Config.load("classpath:" + wechatConfigPath);
        //获取appId
        String appId = wechatConfigProperties.get("wx.appId");
        WxParam.appId = appId == null ? WxParam.appId : appId;
        //获取checkToken
        String checkToken = wechatConfigProperties.get("wx.checkToken");
        WxParam.checkToken = checkToken == null ? WxParam.checkToken : checkToken;
        //获取appSecret
        String appSecret = wechatConfigProperties.get("wx.appSecret");
        WxParam.appSecret = appSecret == null ? WxParam.appSecret : appSecret;
        //获取程序version
        String version = wechatConfigProperties.get("wx.version");
        WxParam.version = version == null ? WxParam.version : version;
        //获取认证回调页面authoRecallUrl
        String authoRecallUrl = wechatConfigProperties.get("wx.authoRecallUrl");
        WxParam.authoRecallUrl = authoRecallUrl == null ? WxParam.authoRecallUrl : authoRecallUrl;
        //获取提前时间
        String expireTimeAhead = wechatConfigProperties.get("wx.expireTimeAhead");
        WxParam.expireTimeAhead = expireTimeAhead == null ? WxParam.expireTimeAhead : Long.parseLong(expireTimeAhead);
    }

}
